/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.ruby_string.delayed;

import moved.org.objectweb.asm.AnnotationVisitor;

public class DelayedAnnotationMutator implements AnnotationVisitor {
	private final AnnotationInstructions annotationInstructions;
	
	public DelayedAnnotationMutator() {
		this(new DefaultAnnotationInstructions());
	}

	public DelayedAnnotationMutator(AnnotationInstructions annotationInstructions) {
		this.annotationInstructions = annotationInstructions;
	}

	public void accept(AnnotationVisitor annotationVisitor) {
		annotationInstructions.accept(annotationVisitor);
	}

	public void visit(String name, Object value) {
		annotationInstructions.add(new AnnotationValue(name, value));
	}

	public AnnotationVisitor visitArray(String name) {
		DelayedAnnotationMutator delayedAnnotationMutator = new DelayedAnnotationMutator();

		annotationInstructions.add(new ArrayAnnotation(name, delayedAnnotationMutator));

		return delayedAnnotationMutator;
	}

	public void visitEnum(String name, String desc, String value) {
		annotationInstructions.add(new EnumInstruction(name, desc, value));
	}

	public AnnotationVisitor visitAnnotation(String name, String desc) {
		DelayedAnnotationMutator delayedAnnotationMutator = new DelayedAnnotationMutator();

		annotationInstructions.add(new DescribedAnnotation(name, desc, delayedAnnotationMutator));

		return delayedAnnotationMutator;
	}

	public void visitEnd() {
	}
}
